package com.seed.web.struts.sysmanager;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.seed.commons.dbquery.PageViewForSQL;
import com.seed.service.sysmanager.IEmployee;
import com.seed.web.core.BaseActionSupport;
import com.seed.web.form.sysmanager.EmployeeForm;

@Controller
@Scope("prototype")
public class EmployeeAction extends BaseActionSupport{

	private static final long serialVersionUID = 1L;

	private EmployeeForm emp ;
	
	public EmployeeForm getEmp() {
		return emp;
	}

	public void setEmp(EmployeeForm emp) {
		this.emp = emp;
	}

	@Resource(name="pageViewForSQL")
	private PageViewForSQL pv ;
	
	public PageViewForSQL getPv() {
		return pv;
	}

	public void setPv(PageViewForSQL pv) {
		this.pv = pv;
	}

	@Resource
	private IEmployee empService ;
	
	public String saveEmp() throws Exception {
		boolean flag = this.empService.saveEmployee(emp) ;
		if(flag) {
			saveMessage("员工添加成功！") ;
		} else {
			saveMessage("员工添加 失败！") ;
		}
		return "msg" ;
	}
	
	public String findEmp() throws Exception {
		pv.setPageModel(this.empService.getScrollData(pv.getFirstResult(), pv.getLineSize())) ;
		this.getBaseform().getRequest().setAttribute("scrolldata", pv) ;
		return "findemp" ;
	}
}
